/**
 * Copyright (C), 2021, 因特驰
 * FileName: BuycarController
 * Author:   李晋武
 * Date:     2021/7/19 3:28
 * Description:
 * History:
 * 李晋武          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.esc.controller;

import com.esc.model.*;
import com.esc.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 〈一句话功能简述〉<br> 
 * 〈〉
 *
 * @author Yun
 * @create 2021/7/19
 * @since 1.0.0
 */
@Controller
@RequestMapping("buycar")
public class BuycarController {

    @Autowired
    private PinpaiService pinpaiService;
    @Autowired
    private ChexiService chexiService;
    @Autowired
    private JiageService jiageService;
    @Autowired
    private JibieService jibieService;
    @Autowired
    private ChelingService chelingService;
    @Autowired
    private CheService cheService;

    @RequestMapping("index")
    public String index(Model model, HttpServletRequest request) {

        //买家登录
        String buyerName = (String) request.getSession().getAttribute("buyerName");
        if (buyerName != null) {
            model.addAttribute("buyerName", buyerName);
            //request.getSession().setAttribute("sellerName","");
        } else {
            model.addAttribute("buyerName", "");
        }
        //卖家登录
        String sellerName = (String) request.getSession().getAttribute("sellerName");
        if (sellerName != null) {
            model.addAttribute("sellerName", sellerName);
            //request.getSession().setAttribute("buyerName","");
        } else {
            model.addAttribute("sellerName", "");
        }


        List<Pinpai> pinpaiList = pinpaiService.queryPinpaiList();
        model.addAttribute("pinpaiList", pinpaiList);
        List<Chexi> chexiList = chexiService.queryChexiList();
        model.addAttribute("chexiList", chexiList);
        List<Jiage> jiageList = jiageService.queryJiageList();
        model.addAttribute("jiageList", jiageList);
        List<Jibie> jibieList = jibieService.queryJibieList();
        model.addAttribute("jibieList", jibieList);
        List<Cheling> chelingList = chelingService.queryChelingList();
        model.addAttribute("chelingList",chelingList);

        //模糊查询条件 queryVal
        String queryVal = "";
        List<Che> cheList = cheService.queryCheList();
        model.addAttribute("queryVal",queryVal);
        model.addAttribute("cheList",cheList);

        return "buycar/index";
    }

}